//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "tyr_drones\fn_droneTestDistance.sqf"
#include <core_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_drone","_max_dist","_result","_dist"];
PARAMS_2(_drone,_max_dist);

_dist = ([_drone,player] call mso_core_fnc_groundDist);
_result = _dist > _max_dist;

if (_dist > (_max_dist * 0.8)) then {
	if (!GVAR(DRONE_DIST_REACHED)) then {
		GVAR(DRONE_DIST_REACHED) = true;
		PAPABEAR sideChat format [localize "STR_TYR_DRN_APPROACHINGLIMIT", group player];
	};
};
if (_dist < (_max_dist * 0.65)) then {
	GVAR(DRONE_DIST_REACHED) = false;
};

TRACE_1("End",_result);
TMFPROFILERSTOP;
_result